from qq_music_text.items import QqMusicTextItem
import scrapy


class File2Spider(scrapy.Spider):
    name = 'file_2'
    allowed_domains = ['y.qq.com']
    start_urls = ['https://y.qq.com/n/ryqq/category']

    def parse(self, response):
        # self.log(response.headers)
        lis = response.xpath("/html/body/div/div/div[2]/div[2]/div[2]/ul/li")
        if lis:
            item = QqMusicTextItem()
            for li in lis:
                ##注意在下载图片的时候url必须以列表的形式表示，字符串的形式会出现错误
                item['image_url'] = ['https:'+ li.xpath('./div/div/a/img/@src').extract()[0]]
                # item['标题'] = ''
                yield item
        
